package com.bbdjt.weixin.service.impl;

import java.util.List;


import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.StringUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.bbdjt.weixin.model.ForumPostQueryModel;
import com.bbdjt.weixin.base.service.impl.BaseServiceImpl;
import com.bbdjt.weixin.dao.ForumPostDao;
import com.bbdjt.weixin.model.ForumPost;
import com.bbdjt.weixin.service.ForumPostService;

@Service("forumPostService")
public class ForumPostServiceImpl extends BaseServiceImpl<ForumPost> implements ForumPostService {
	
	@Override
    public List<ForumPost> selectByForumPost(ForumPost forumPost, int page, int rows) {
        Example example = new Example(ForumPost.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo(forumPost);
        PageHelper.startPage(page, rows);
        return selectByExample(example);
    }
    
    @Override
    public List<ForumPost> selectByForumPost(ForumPost forumPost) {
        Example example = new Example(ForumPost.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo(forumPost);
        return selectByExample(example);
    }

    @Override
    public PageInfo<ForumPostQueryModel> selectByForumPostQueryModel(ForumPostQueryModel forumPost) {
    	return ((ForumPostDao) getMapper()).selectByForumPostModel(forumPost);
    }

	@Override
	public List<ForumPost> selectByForumPost(ForumPostQueryModel forumPost) {
		  Example example = new Example(ForumPost.class);
	        Example.Criteria criteria = example.createCriteria();
	        criteria.andEqualTo(forumPost);
	        PageHelper.startPage(forumPost.getPageNum(), forumPost.getPageSize(),forumPost.getOrderBy());
	        return selectByExample(example);
	}

	@Override
	public List<ForumPost> selectAllForumPost(ForumPost forumPost) {
		return ((ForumPostDao) getMapper()).selectAllForumPost(forumPost);
	}

	@Override
	public ForumPost selectDetailsForumPost(ForumPost forumPost) {
		return ((ForumPostDao) getMapper()).selectDetailsForumPost(forumPost);
	}

}